package gimys;

import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureImpl;
import org.newdawn.slick.opengl.renderer.LineStripRenderer;
import org.newdawn.slick.opengl.renderer.Renderer;
//import org.newdawn.slick.opengl.renderer.SGL;

public class ShapeDraw {
	/** The renderer to use for all GL operations */
	//private static SGL GL = Renderer.get();
	/** The renderer to use line strips */
	private static LineStripRenderer LSR = Renderer.getLineStripRenderer();
	

	
    /**
     * Draw the outline of the given shape.  Only the vertices are set.  
     * The colour has to be set independently of this method.
     * 
     * @param shape The shape to draw.
     */
    public static final void draw(Shape shape, float panX ,float panY) {
        Texture t = TextureImpl.getLastBind();
        TextureImpl.bindNone();
        
        float points[] = shape.getPoints();
       
        LSR.start();
        for(int i=0;i<points.length;i+=2) {
        	LSR.vertex(points[i]-panX, points[i + 1]-panY);
        }
        
        if (shape.closed()) {
        	LSR.vertex(points[0]-panX, points[1]-panY);
        }
        
        LSR.end();
        
        if (t == null) {
        	TextureImpl.bindNone();
        } else {
        	t.bind();
        }
    }



	public static void agro(Shape collisionShape, float radius, float panX, float panY) {
		Circle cercl = new Circle( collisionShape.getCenterX(), collisionShape.getCenterY(), radius);
		draw(cercl, panX, panY);
	}

	
}
